<?php

#doc
#	classname:	QuserController
#	scope:		PUBLIC
#
#/doc

class QuserController extends Controller
{
	
	public function filters()
		{
			return array(
				'accessControl',
			);
		}

		public function accessRules()
		{
		return array(


		array('allow',
			'actions'=>array('add','Edit','Delete'),
			'roles'=>array('admin')

			),
			array('deny',
			'actions'=>array('add','Edit','Delete'),
			'users'=>array('*')

			),


		);
	 }
	
	public function actionLogout ()
	{
		Yii::app()->user->logout();
		$this->redirect(Yii::app()->homeUrl);
	}
	
	public function actionIndex()
	{
		$model=new User;

		if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
		{
			echo CActiveForm::validate($model);
			Yii::app()->end();
		}

		if(isset($_POST['LoginForm']))
		{
			$model->attributes=$_POST['LoginForm'];
			// validate user input and redirect to the previous page if valid
			if($model->validate() && $model->login())
				$this->redirect('/adminka/qnews/add');
		}

		$this->render('application.views.qlogin.login',array('model'=>$model));
	}
}
###

?>